package homework.xuluoxi;

/*
 * 作业名称：斗地主（非完整）
 * 作业功能：实现简易斗地主部分功能
 * 分　　类：卡牌部分
 * 学　　员：徐罗希
 * 版　　本：V1.0
 * 备　　注：模块三作业
 */

public class Card {

    // 1、定义扑克牌的成员变量
    private CardType type;
    private CardNumber number;

    // 2、构造方法、get、set方法
    public Card() {}

    public Card(CardType type, CardNumber number) {
        setType(type);
        setNumber(number);
    }

    public CardType getType() {
        return type;
    }

    public void setType(CardType type) {
        this.type = type;
    }

    public CardNumber getNumber() {
        return number;
    }

    public void setNumber(CardNumber number) {
        this.number = number;
    }

    // 3、自定义准备54张扑克牌的方法
    public static Card[] cardReady() {

        // 准备花色
        CardType spade = CardType.SPADE;
        CardType heart = CardType.HEART;
        CardType club = CardType.CLUB;
        CardType diamond = CardType.DIAMOND;
        CardType joker = CardType.JOKER;

        // 准备数字
        CardNumber one = CardNumber.A;
        CardNumber two = CardNumber.TWO;
        CardNumber three = CardNumber.THREE;
        CardNumber four = CardNumber.FOUR;
        CardNumber five = CardNumber.FIVE;
        CardNumber six = CardNumber.SIX;
        CardNumber seven = CardNumber.SEVEN;
        CardNumber eight = CardNumber.EIGHT;
        CardNumber nine = CardNumber.NINE;
        CardNumber ten = CardNumber.TEN;
        CardNumber j = CardNumber.J;
        CardNumber q = CardNumber.Q;
        CardNumber k = CardNumber.K;
        CardNumber sJoker = CardNumber.SJOKER;
        CardNumber bJoker = CardNumber.BJOKER;

        // 准备54张扑克牌
        Card[] cardSet = new Card[54];
        for (int n = 5; n >= 1; n --) {
            for (int m = 0; m <= 12; m ++) {
                if (n == 5) {
                    cardSet[0] = new Card(joker, bJoker);
                    cardSet[1] = new Card(joker, sJoker);
                    break;
                }
                if (n == 4) {
                    switch (m) {
                        case 0 : cardSet[m + 2] = new Card(spade, two); break;
                        case 1 : cardSet[m + 5] = new Card(spade, one); break;
                        case 2 : cardSet[m + 8] = new Card(spade, k); break;
                        case 3 : cardSet[m + 11] = new Card(spade, q); break;
                        case 4 : cardSet[m + 14] = new Card(spade, j); break;
                        case 5 : cardSet[m + 17] = new Card(spade, ten); break;
                        case 6 : cardSet[m + 20] = new Card(spade, nine); break;
                        case 7 : cardSet[m + 23] = new Card(spade, eight); break;
                        case 8 : cardSet[m + 26] = new Card(spade, seven); break;
                        case 9 : cardSet[m + 29] = new Card(spade, six); break;
                        case 10 : cardSet[m + 32] = new Card(spade, five); break;
                        case 11 : cardSet[m + 35] = new Card(spade, four); break;
                        case 12 : cardSet[m + 38] = new Card(spade, three);
                    }
                }
                if (n == 3) {
                    switch (m) {
                        case 0 : cardSet[m + 3] = new Card(heart, two); break;
                        case 1 : cardSet[m + 6] = new Card(heart, one); break;
                        case 2 : cardSet[m + 9] = new Card(heart, k); break;
                        case 3 : cardSet[m + 12] = new Card(heart, q); break;
                        case 4 : cardSet[m + 15] = new Card(heart, j); break;
                        case 5 : cardSet[m + 18] = new Card(heart, ten); break;
                        case 6 : cardSet[m + 21] = new Card(heart, nine); break;
                        case 7 : cardSet[m + 24] = new Card(heart, eight); break;
                        case 8 : cardSet[m + 27] = new Card(heart, seven); break;
                        case 9 : cardSet[m + 30]= new Card(heart, six); break;
                        case 10 : cardSet[m + 33] = new Card(heart, five); break;
                        case 11 : cardSet[m + 36] = new Card(heart, four); break;
                        case 12 : cardSet[m + 39] = new Card(heart, three);
                    }
                }
                if (n == 2) {
                    switch (m) {
                        case 0 : cardSet[m + 4] = new Card(club, two); break;
                        case 1 : cardSet[m + 7] = new Card(club, one); break;
                        case 2 : cardSet[m + 10] = new Card(club, k); break;
                        case 3 : cardSet[m + 13] = new Card(club, q); break;
                        case 4 : cardSet[m + 16] = new Card(club, j); break;
                        case 5 : cardSet[m + 19] = new Card(club, ten); break;
                        case 6 : cardSet[m + 22] = new Card(club, nine); break;
                        case 7 : cardSet[m + 25] = new Card(club, eight); break;
                        case 8 : cardSet[m + 28] = new Card(club, seven); break;
                        case 9 : cardSet[m + 31] = new Card(club, six); break;
                        case 10 : cardSet[m + 34] = new Card(club, five); break;
                        case 11 : cardSet[m + 37] = new Card(club, four); break;
                        case 12 : cardSet[m + 40] = new Card(club, three);
                    }
                }
                if (n == 1) {
                    switch (m) {
                        case 0 : cardSet[m + 5] = new Card(diamond, two); break;
                        case 1 : cardSet[m + 8] = new Card(diamond, one); break;
                        case 2 : cardSet[m + 11] = new Card(diamond, k); break;
                        case 3 : cardSet[m + 14] = new Card(diamond, q); break;
                        case 4 : cardSet[m + 17] = new Card(diamond, j); break;
                        case 5 : cardSet[m + 20] = new Card(diamond, ten); break;
                        case 6 : cardSet[m + 23] = new Card(diamond, nine); break;
                        case 7 : cardSet[m + 26] = new Card(diamond, eight); break;
                        case 8 : cardSet[m + 29] = new Card(diamond, seven); break;
                        case 9 : cardSet[m + 32] = new Card(diamond, six); break;
                        case 10 : cardSet[m + 35] = new Card(diamond, five); break;
                        case 11 : cardSet[m + 38] = new Card(diamond, four); break;
                        case 12 : cardSet[m + 41] = new Card(diamond, three);
                    }
                }
            }
        }
        return cardSet;
    }

    // 4、扑克牌打印方法
    public void cardShow() {
        System.out.print(type.getType() + number.getNumber());
    }
}
